package titt.util.deploy;

public class AutoUpdateCache implements Cache {

	private final Cache c;

	public AutoUpdateCache(Cache c) {
		this.c = c;
	}

	@Override
	public String getMimeType() {
		return c.getMimeType();
	}

	@Override
	public byte[] getValue() {
		try {
			update();
		}
		catch(Exception e) {
			e.printStackTrace();
		}
		return c.getValue();
	}

	@Override
	public boolean isOutdated() {
		return c.isOutdated();
	}

	@Override
	public void update() throws Exception {
		if(c.isOutdated())
			c.update();
	}

}
